The present invention relates generally to software development and more specifically to various aspects of language development within any of various programming languages, such as a platform-independent, object-oriented programming language, as one example.
In various programming languages, parametric polymorphism (e.g., generics) may be considered as a way to make a language more expressive, while still maintaining full static type-safety. Parametric polymorphism may allow a function or a data type to be written in a generic fashion such that it can handle various data types in the same manner regardless of their different types. Such functions and data types may be called generic functions and generic datatypes. For example, a generic list class may be written List <T>, which means that it can be a list of elements of any type T, where T is specified separately from the specification of List.
Frequently, when using object oriented languages that do not provide a single type which can be a supertype for all other types, one cannot generify over certain types without using particular conversion operations, such as boxing (e.g., automatically converting a value of a primitive type, like int, into an object of a corresponding wrapper class like Integer). For example, traditionally the Java™ language does not allow generics over both objects and primitives.
Parametric polymorphism (generics) may also involve a tradeoff between code size, generation costs and type specificity. For example, a programming language may support primitive-specialized generics, but may generates specialized classes statically, thereby at potentially increased cost to code footprint and compilation cost. Another programming language may generate a specialized instantiation of templates for each instantiation used by the program, which may result in a large static footprint. Yet a third language may use a templatized bytecode format, only performing specialization to runtime, which may require an additional step before using a generic class file, thereby potentially harming runtime performance.